const api = "http://127.0.0.1:8989/"

const label = document.getElementById("label")


// 获取设备运行状态
function getStatus() {
    var status = false
    fetch(api + "/getNodeValue")
        .then(res => {
            return res.json()
        })
        .then(data => {
            console.log(data)
            status = data.status
            if (status) {
                label.innerText = "工站状态：运行"
            } else {
                label.innerText = "工站状态：停止"
            }
        })
    return status
}
getStatus()

// 修改设备运行状态
function setStatus(value = true) {
    data = {
        nodeId: "ns=3;i=1014",
        value: value
    }
    // console.log(data);

    fetch(api + "setStatus", {
        method: "POST",
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
        .then(res => {
            console.log(res.json());

        })

    getStatus()

}



